﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UvozCarovnik.aspx.cs" Inherits="Sio.Mdm.Web.Uporabnik.UvozCarovnik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Uvoz podatkov o učečih iz excela</title>
    <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    <script runat="server">
    
        protected void Next_Click(object sender, DirectEventArgs e)
        {
            int index = int.Parse(e.ExtraParams["index"]);


            if (index == 0)
                if (this.PreberiClick(sender, e))
                    if ((index + 1) < this.PanelWizard.Items.Count)
                    {
                        this.PanelWizard.ActiveIndex = index + 1;
                        this.btnUvozi.Show();
                        this.btnNext.Hide();
                        this.btnPrev.Disabled = false;
                    }
        }

        protected void Prev_Click(object sender, DirectEventArgs e)
        {
            int index = int.Parse(e.ExtraParams["index"]);
            this.PanelWizard.ActiveIndex = index - 1;

            this.btnPrev.Disabled = true;
            this.btnNext.Show();
            this.btnUvozi.Hide();
        }
    </script>
    <script type="text/javascript">
        function setButtons() {
            btnUvozi.setDisabled((GridPanel1.getSelectionModel().selections.length < 1));
        }         
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager runat="server" />
    <ext:Store runat="server" ID="StoreSolskaLeta">
        <Reader>
            <ext:JsonReader IDProperty="LetoId">
                <Fields>
                    <ext:RecordField Name="LetoId" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Panel ID="PanelWizard" runat="server" Padding="15" Height="300" Layout="card"
        ActiveIndex="0">
        <Items>
            <ext:Panel ID="PanelFile" runat="server" Border="false" Header="false" Title="Nastavitve uvoza">
                <Items>
                    <ext:ComboBox ID="cbSolskoLeto" StoreID="StoreSolskaLeta" DisplayField="Naziv" ValueField="LetoId"
                        Mode="Local" ForceSelection="true" TriggerAction="All" FieldLabel="Šolsko leto"
                        LabelAlign="Top" runat="server" Editable="false" SelectOnFocus="true" Width="300"
                        EmptyText="Izberite šolsko leto ...">
                    </ext:ComboBox>
                    <ext:FileUploadField ID="BasicField" runat="server" Width="300" ButtonText="Išči..."
                        AnchorHorizontal="98%" Icon="Attach" Visible="true">
                    </ext:FileUploadField>
                    <ext:Checkbox runat="server" ID="chkUstvariRazrede" FieldLabel="Avtomatsko dodaj manjkajoče razrede">
                    </ext:Checkbox>
                </Items>
            </ext:Panel>
            <ext:Panel ID="PanelUvoz" runat="server" Title="Izberite učeče za uvoz" Width="600"
                Height="350" Layout="fit">
                <Items>
                    <ext:GridPanel ID="GridPanel1" runat="server" StripeRows="true" TrackMouseOver="true"
                        Hidden="false" Border="false">
                        <Store>
                            <ext:Store ID="Store1" runat="server">
                                <Reader>
                                    <ext:JsonReader IDProperty="Uid">
                                        <Fields>
                                            <ext:RecordField Name="Ime" />
                                            <ext:RecordField Name="Priimek" />
                                            <ext:RecordField Name="Spol" />
                                            <ext:RecordField Name="Emso" />
                                            <ext:RecordField Name="Naslov" />
                                            <ext:RecordField Name="Posta" />
                                            <ext:RecordField Name="Email" />
                                            <ext:RecordField Name="Telefon" />
                                            <ext:RecordField Name="Razred" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <ColumnModel runat="server">
                            <Columns>
                                <ext:RowNumbererColumn />
                                <ext:Column Header="Ime" DataIndex="Ime">
                                </ext:Column>
                                <ext:Column Header="Priimek" DataIndex="Priimek">
                                </ext:Column>
                                <ext:Column Header="Spol" DataIndex="Spol">
                                </ext:Column>
                                <ext:Column Header="Emšo" DataIndex="Emso">
                                </ext:Column>
                                <ext:Column Header="Naslov" DataIndex="Naslov">
                                </ext:Column>
                                <ext:Column Header="Pošta" DataIndex="Posta">
                                </ext:Column>
                                <ext:Column Header="E-naslov" DataIndex="Email">
                                </ext:Column>
                                <ext:Column Header="Telefon" DataIndex="Telefon">
                                </ext:Column>
                                <ext:Column Header="Razred" DataIndex="Razred">
                                </ext:Column>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel runat="server">
                                <Listeners>
                                    <SelectionChange Handler="setButtons();"/>
                                </Listeners>
                            </ext:CheckboxSelectionModel>
                        </SelectionModel>
                        <LoadMask ShowMask="true" />
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
            <ext:Panel ID="PanelFinish" runat="server" Width="600" Height="350" Layout="fit"
                Border="false">
                <Items>
                    <ext:GridPanel ID="GridPanel2" runat="server" StripeRows="true" TrackMouseOver="true"
                        Hidden="true" Title="Podvojeni podatki" Border="false">
                        <Store>
                            <ext:Store ID="Store2" runat="server">
                                <Reader>
                                    <ext:JsonReader IDProperty="Uid">
                                        <Fields>
                                            <ext:RecordField Name="Ime" />
                                            <ext:RecordField Name="Priimek" />
                                            <ext:RecordField Name="Spol" />
                                            <ext:RecordField Name="Emso" />
                                            <ext:RecordField Name="Naslov" />
                                            <ext:RecordField Name="Posta" />
                                            <ext:RecordField Name="Email" />
                                            <ext:RecordField Name="Telefon" />
                                            <ext:RecordField Name="Razred" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:RowNumbererColumn />
                                <ext:Column Header="Ime" DataIndex="Ime">
                                </ext:Column>
                                <ext:Column Header="Priimek" DataIndex="Priimek">
                                </ext:Column>
                                <ext:Column Header="Spol" DataIndex="Spol">
                                </ext:Column>
                                <ext:Column Header="Emšo" DataIndex="Emso">
                                </ext:Column>
                                <ext:Column Header="Naslov" DataIndex="Naslov">
                                </ext:Column>
                                <ext:Column Header="Pošta" DataIndex="Posta">
                                </ext:Column>
                                <ext:Column Header="E-naslov" DataIndex="Email">
                                </ext:Column>
                                <ext:Column Header="Telefon" DataIndex="Telefon">
                                </ext:Column>
                                <ext:Column Header="Razred" DataIndex="Razred">
                                </ext:Column>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel runat="server">
                            </ext:CheckboxSelectionModel>
                        </SelectionModel>
                        <LoadMask ShowMask="true" />
                    </ext:GridPanel>
                    <ext:Label ID="Label1" runat="server" Html="<h1>Čestitamo!</h1><br><p>Uspešno ste zaključili uvoz podatkov!</p>"
                        Hidden="true" />
                </Items>
            </ext:Panel>
        </Items>
        <Buttons>
            <ext:Button ID="btnPrev" runat="server" Text="Nazaj" Disabled="true" Icon="PreviousGreen">
                <DirectEvents>
                    <Click OnEvent="Prev_Click">
                        <ExtraParams>
                            <ext:Parameter Name="index" Value="#{PanelWizard}.items.indexOf(#{PanelWizard}.layout.activeItem)"
                                Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="btnNext" runat="server" Text="Naprej" Icon="NextGreen">
                <DirectEvents>
                    <Click OnEvent="Next_Click">
                        <ExtraParams>
                            <ext:Parameter Name="index" Value="#{PanelWizard}.items.indexOf(#{PanelWizard}.layout.activeItem)"
                                Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="btnUvozi" runat="server" Text="Uvozi v bazo" Icon="Accept" Hidden="true" Disabled="true">
                <DirectEvents>
                    <Click OnEvent="UvoziClick">
                        <Confirmation ConfirmRequest="true" Message="Uvozim izbrane zapise?" />
                        <ExtraParams>
                            <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true}))" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </Buttons>
    </ext:Panel>
    </form>
</body>
</html>
